package com.futures.questionbank.ui.home;

import android.content.Intent;

import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.futures.questionbank.R;
import com.futures.questionbank.Utils.UItils;
import com.futures.questionbank.adapter.BaseViewHolder;
import com.futures.questionbank.base.BaseActivity;
import com.futures.questionbank.db.table.problem;
import com.futures.questionbank.db.table.problem_Table;
import com.futures.questionbank.main.ExamActivity;
import com.raizlabs.android.dbflow.sql.language.SQLite;

import java.util.List;

public class SectionActivity2 extends BaseActivity {
    private RecyclerView rv;
    private List<problem> problems;


    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.section_activity);
        setTitle("章节测试题");
    }

    @Override
    protected void loadData() {
        initView();
    }

    private void initView() {
        UItils.showDialog(SectionActivity2.this);
        int chapter_id = getIntent().getIntExtra("index",0);
        problems = SQLite.select().
                from(problem.class).where(problem_Table.exam_id.eq(chapter_id)).queryList();

        rv =  findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(this));
        //设置Item增加、移除动画
        rv.setItemAnimator(new DefaultItemAnimator());
        //SectionAdpter chapterAdpter = new (this, problems, new TypeItemListener());
      //  rv.setAdapter(chapterAdpter);
    }

    class TypeItemListener implements BaseViewHolder.onItemCommonClickListener {
        @Override
        public void onItemClickListener(int position) {
            Intent intent = new Intent();
            //intent.putExtra("index", sections1.get(position).getExam_id());
            intent.setClass(SectionActivity2.this, ExamActivity.class);
            startActivity(intent);
        }

        @Override
        public void onItemLongClickListener(int position) {

        }
    }
}